using fwt
using gfx
using swtChartWrapper

class Trial1
{
  public static Void main ()
  {
    // define the series of data points to display
    series := LineSeries
    {
      label = "line series"
      points = [0.0f, 0.4f, 0.7f, 0.9f, 1.0f, 0.9f, 0.7f, 0.4f, 0.0f, -0.4f, -0.7f, -0.9f, -1.0f, -0.9f, -0.7f, -0.4f]
    }
    chart := Chart
    {
      title.text = "Line Chart Example"
      xAxis.title.text = "Data Points"
      yAxis.title.text = "Amplitude"
      data = [series]
    }

    // define a window to display the chart in
    Window
    {
      title = "Example Chart"
      size = Size(450, 350)
      EdgePane
      {
        top  = Button
        {
          text = "click"
          onAction.add |Event e| 
          { 
            chart.yAxis.range = [-5.0f, 10.0f]
            chart.xAxis.zoomInAt (20.0f)
          }
        }
        center = chart
        left = Button
        {
          text = "Zoom in"
          onAction.add |Event e|
          {
            chart.zoomIn
          }
        }
        right = Button
        {
          text = "Zoom out"
          onAction.add |Event e|
          {
            chart.zoomOut
          }
        }
        bottom = Button
        {
           text = "Info"
           onAction.add |Event e|
           {
             echo ("xAxis range: " + chart.xAxis.range)
             echo ("yAxis range: " + chart.yAxis.range)
           }
        }
      },      
    }.open
  }
}
